function rate(id,action) {
  var url = "/post/"+id+"/"+action;
  var http = new XMLHttpRequest();
  http.open("POST",url,true);

  http.setRequestHeader("Content-type", "text/plain");
  http.setRequestHeader("Content-length", 0);
  http.setRequestHeader("Connection", "close");

  http.onreadystatechange = function() {
    if(http.readyState == 4 && http.status == 200) {
      document.getElementById(id + "_votes").innerHTML = "Rating: " + http.responseText;
    }
  }
  http.send();
}
